<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: stats_products_purchased.php 116 2013-09-21 12:08:56Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 116 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-21 12:08:56 +0000 (Sat, 21 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */


  require('includes/application_top.php');
  require(DIR_WS_INCLUDES.'metatag.php');
?>
</head>
<body>
<?php require(DIR_WS_INCLUDES.'header.php'); ?>
<div id="wrapper">
<table class="outerTable" cellspacing="0" cellpadding="0">
  <tr>
    <td class="columnLeft2" width="<?php echo BOX_WIDTH; ?>" valign="top">
		<table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
			<?php require(DIR_WS_INCLUDES.'column_left.php'); ?>
        </table>
	</td>
    <td class="boxCenter" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  		<tr>
		    <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
		</tr>
		</table>
		</td>
      </tr>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td valign="top">
			 <table border="0" width="100%" cellspacing="0" cellpadding="0" class="dataTable">
              <tr class="dataTableHeadingRow">
                <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_NUMBER; ?></td>
                <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS; ?></td>
                <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_PURCHASED; ?>&nbsp;</td>
              </tr>
				<?php
				  if ($_GET['page'] > 1) $rows = $_GET['page'] * '20' - '20';

					$sql = ("SELECT
								p.products_id,
								p.products_ordered,
								pd.products_name
							FROM
								".TABLE_PRODUCTS." p,
								".TABLE_PRODUCTS_DESCRIPTION." pd
							WHERE
								pd.products_id = p.products_id
							AND
								pd.language_id = '".$_SESSION['languages_id']."'
							AND
								p.products_ordered > 0
							GROUP BY
								pd.products_id
							ORDER BY
								p.products_ordered DESC, pd.products_name");
				  
				  $query = page_break_create($_POST['per_site'], $_GET['page'], $sql, 'stats_products_purchased.php');
				$products = $query['query'];
				  
				while (!$products->EOF) {
				    $rows++;

				    if (strlen($rows) < 2) {
				      $rows = '0'.$rows;
				    }
					if ($rows % 2 == 0)
			    		$f = 'dataTableRow';
			    	else
			    		$f = ''; ?>
				<tr class="<?php echo $f ?>" onmouseover="this.className='dataTableRowOver';this.style.cursor='pointer'" onmouseout="this.className='<?php echo $f ?>'"  onclick="document.location.href='<?php echo href_link(FILENAME_CATEGORIES, 'action=new_product_preview&read=only&pID='.$products->fields['products_id'].'&origin='.FILENAME_STATS_PRODUCTS_PURCHASED.'?page='.$_GET['page'], 'NONSSL'); ?>'">
                	<td class="dataTableContent"><?php echo $rows; ?>.</td>
                	<td class="dataTableContent"><?php echo $products->fields['products_name']; ?></td>
                	<td class="dataTableContent" align="center"><?php echo $products->fields['products_ordered']; ?>&nbsp;</td>
              </tr>
<?php
$products->MoveNext();
  }
?>
            </table></td>
                        <table border="0" width="100%" cellspacing="0" cellpadding="2">
             <tr class="page_break">
					<td class="smallText" valign="top" width="33.3%"><?php echo 'Angezeigt werden '.$query['from'].' bis '.$query['to'].' (von insgesamt '.$query['total'].' Artikeln)'; ?></td>
					<td class="smallText" align="center" width="33.3%"></td>
					<td class="smallText" align="right" width="33.3%">
						Artikel pro Seite: <?php echo $query['page_break']->perSiteDropdown($_GET['page']); ?>
					</td>
				</tr>
				<tr><td align="center" colspan="3"><?php echo '<br />'.$query['links']; ?></td></tr>
            </table>
          </tr>
          <tr>
            <td colspan="3"><table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr>
                <td class="smallText" valign="top"></td>
                <td class="smallText" align="right"></td>
              </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
</div>
<?php require(DIR_WS_INCLUDES.'footer.php'); ?>
</body>
</html>
<?php require(DIR_WS_INCLUDES.'application_bottom.php'); ?>